*
* $Id$
*
* $Log: settrk.F,v $
* Revision 1.1.1.1  2002/06/16 15:18:40  hristov
* Separate distribution  of Geant3
*
* Revision 1.1.1.1  1999/05/18 15:55:19  fca
* AliRoot sources
*
* Revision 1.1.1.1  1995/10/24 10:21:00  cernlib
* Geant
*
*
#include "geant321/pilot.h"
*CMZ :  3.21/02 29/03/94  15.41.38  by  S.Giani
*-- Author :
      SUBROUTINE SETTRK(NTR)
C
C *** FILL THE STACK VIA COMMON /EVENT/ ***
C *** INSTEAD OF THE USERWORD, THE PARTICLE INDEX IS STORED ***
C *** NVE 01-MAR-1988 CERN GENEVA ***
C
C ORIGIN : H.FESEFELDT (10-NOV-1983)
C
#include "geant321/gcking.inc"
#include "geant321/s_defcom.inc"
C
C --- CHECK PV ARRAY BOUNDARY ---
      IF(NTR .LE. MXGKPV) GOTO 10
      PRINT 1000,NTR
 1000 FORMAT(' *SETTRK* NTR = ',I3,' WOULD ADRESS OUTSIDE PV ARRAY'/
     $ ' ===> TRACK WILL NOT BE PUT ON STACK AND WILL BE LOST')
      GO TO 9999
C
C --- CHECK TOTAL NUMBER OF PRODUCED PARTICLES ---
 10   CONTINUE
      NVEDUM=NTOT+1
      IF(NVEDUM .LE. MXEVEN) GOTO 20
      IF(NVEDUM .EQ. MXEVEN+1) PRINT 1001, NVEDUM,MXEVEN
 1001 FORMAT(' *SETTRK* STORAGE OF PARTICLE NO. ',I4, 'NOT ALLOWED'/
     $ ' MAXIMUM NUMBER OF GENERATED PARTICLES IS ',I4/
     $ ' ===> FROM NOW ON ALL GENERATED PARTICLES WILL BE DISCARDED')
      GO TO 9999
C
C --- STORE GENERATED PARTICLE ON THE STACK ---
 20   CONTINUE
      EVE(NEXT   )=XEND
      EVE(NEXT+ 1)=YEND
      EVE(NEXT+ 2)=ZEND
      EVE(NEXT+ 3)=RCA
      EVE(NEXT+ 4)=RCE
      EVE(NEXT+ 5)=PV(5,NTR)
      EVE(NEXT+ 6)=PV(6,NTR)
      EVE(NEXT+ 7)=PV(7,NTR)
      EVE(NEXT+ 8)=PV(1,NTR)
      EVE(NEXT+ 9)=PV(2,NTR)
      EVE(NEXT+10)=PV(3,NTR)
      EVE(NEXT+11)=PV(8,NTR)
      NEXT=NEXT+12
      NTOT=NTOT+1
      NEXT1=NEXT-12
      NEXT2=NEXT-1
      NTOT1=NTOT-1
      IF(NPRT(3).OR.NPRT(4).OR.NPRT(5))
     $ WRITE(NEWBCD,2000) NTOT1,(EVE(I),I=NEXT1,NEXT2)
 2000 FORMAT(' *SETTRK* TRACK ON STACK:',I5,2X,3F8.2,1X,2F7.0,1X,
     $ F8.3,1X,F3.0,1X,F6.0,1X,3F8.3,1X,F10.0)
C
 9999 CONTINUE
      RETURN
      END
